<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>普通资产管理</title>
		<!--<link rel="stylesheet" href="../layui/css/layui.css" />
		<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>-->
	</head>
	<body>
		<div class="layui-elem-quote">
			<span class="layui-breadcrumb">
				<a href="javascript:toIndex();"><span class="layui-icon layui-icon-home"></span> 首页</a>
				<a href="javascript:;"><span class="layui-icon layui-icon-layouts"></span> 资产信息管理</a>
				<a href="javascript:;"><cite><span class="layui-icon layui-icon-home"></span> 普通资产信息</cite></a>
			</span>
		</div>
		<div>
			<form class="layui-form">
			<div class="layui-inline" >
			<label class="layui-form-label">资产分类：</label>
			<div class="layui-input-inline" >
			<select id="cityList" name="" lay-filter="form">
				<option value="">全部</option>
			</select>
			</div>
			</div>
			<div class="layui-inline" >
			
			<div class="layui-input-inline">
			<select id="proList" name="">
				<option value="">全部</option>
			</select>
		
		</div>
		</div>
		
			<div class="layui-inline">
			<label class="layui-form-label">资产名称：</label>
			<div class="layui-input-inline">
			<input type="text" id="" class="layui-input"/>
		</div>
		</div>
		    <div class="layui-inline">
			<label class="layui-form-label">资产编号：</label>
			<div class="layui-input-inline">
			<input type="text" id="" class="layui-input" />
		</div>
		</div>
		</from>
		<br />
		<br />
	
	
		<form class="layui-form">
			<div class="layui-inline">
		<label class="layui-form-label">包装类型：</label>
			<div class="layui-input-inline">
			<select name="">
				<option value="">全部</option>
				<option value="">桶</option>
				<option value="">瓶</option>
				<option value="">箱</option>
				<option value="">袋</option>
				<option value="">盒</option>
				<option value="">罐</option>
				<option value="">散装</option>
				<option value="">套</option>
				<option value="">台</option>
			</select>
			</div>
			
			<div class="layui-inline">
			<label class="layui-form-label">供应商信息</label>
			<div class="layui-input-inline">
			<input type="text" id="" class="layui-input"/>
		</div>
		</div>
	
	<div class="layui-inline">
			<label class="layui-form-label">耗材：</label>
		<input id="rememberPwd" type="checkbox" name="switch" lay-skin="switch"  lay-text=" 是| 否">
	</div>
	
		
		<div class="layui-inline">
			<div class="layui-input-inline">
				<a href="" class="layui-btn layui-btn-success"><span class="layui-icon layui-icon-search"></span> 检索Search</a>
			</div>
		</div>
  </form>
</div>
	<div class="layui-card">
		<div class="layui-card-header">
			可领用资产列表
		</div>
		<div class="layui-card-body">
			<table id="demo" lay-filter="test"></table>
		</div>
		<script type="text/html" id="toolbar1">
			<div>
				<a class="layui-btn layui-bg-blue" lay-event="add">
					<span class="layui-icon layui-icon-add-1"></span>新建资产 Add
				</a>
				<a class="layui-btn layui-bg-cyan" lay-event="delete">
					<span class="layui-icon layui-icon-download-circle"></span>资产入库 Instock
				</a>
				<a class="layui-btn layui-bg-orange" lay-event="edit">
					<span class="layui-icon layui-icon-edit"></span>编辑资产 Edit
				</a>

			</div>
		</script>

		<script src="layui/layui.js"></script>
		<script src="layui/layui.all.js"></script>
		<script>
			layui.use(["element",'form','jquery',"layer",'table'],function(){
				var myelement = layui.element;
				var form1 = layui.form;
				var $ = layui.$;
				var layer = layui.layer;
				var table = layui.table;
				loadCity($,form1);
				form1.on('select(form)',function(object){
					loadProList($,object.value);
				});
			});
			
			function loadCity($){
				$.ajax({
					type:"get",
					url:"LianJiJSON/cityData.json",
					async:true,
					success:function(result){
						var arr = result.city;
						var str = "<option value='all'>全部</option>";
						$.each(arr,function(index,value){
							str += "<option value='" + arr[index].cityName + "'>" + arr[index].cityName + "</option>"
						});
						//alert(str);
							$("#cityList").html(str);
							layui.form.render();
					}
				});
			}
			
			function loadProList($,data){
				$.ajax({
					type:"get",
					url:"LianJiJSON/cityData.json",
					async:true,
					success:function(result){
						var arr = result.city;
						$.each(arr,function(index,v){
							if(data == arr[index].cityName){
								var list = arr[index].cityList;
								var str = "<option value='all'>全部</option>";
								$.each(list,function(index,value){
									str += "<option value='" + list[index] + "'>" + list[index] +"</option>";
								});
								$("#proList").html(str);
								layui.form.render();
							}
						});
					}
				});
			}
		</script>
		<script>
			layui.use(['element', 'form', 'laypage', 'table', 'jquery'],
					function() {
						var element = layui.element;
						var $ = layui.$;
						var form = layui.form;
						var laypage = layui.laypage;
						var table = layui.table;
						table.render({
							elem: '#demo',
							url: 'dataJSON/paintAssetInfo.json' //数据接口
								,
							toolbar: "#toolbar1",
							id: "test1",
							page: true //开启分页
								,
							limit: 5,
							limits: [5, 10, 15, 20],
							loading: false,
							done: function(res, curr, count) {
								console.log(res, curr, count);
							},
							cols: [
								[ //表头
									{
										type: "checkbox"
									}, {
										field: 'id',
										title: '资产编号',
										sort:true,
										width: 200
									}, {
										field: 'showValue',
										title: '资产名称',
										width: 260
									}, {
										field: 'class',
										title: '品牌',
										width: 160,
									}, {
										field: 'desc',
										title: '型号',
										width: 200
									}, {
										field: 'name',
										title: '供货商',
										width: 200
									}, {
										field: "",
										title: '库存记录',
										templet: function(data) {
												var str1 = "<a lay-event='row_edit' href='javascript:;' class='layui-btn layui-bg-success'><span class='layui-icon layui-icon-template-1'></span>记录</a>";
										
											return str1;
										}
									}

								]
							]
						});
							table.on("toolbar(test)", function(obj) {
						var data = obj.data;
						var event1 = obj.event;
						if(event1 === "add") {
							layer.open({
								title: "添加用户",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
							table.reload();
						}
						if(event1 === "delete") {
							var tbl_data =
								table.checkStatus("test1");
							var data = tbl_data.data;
							if(tbl_data .data.length == 0) {
								layer.alert("请选择一行数据");
							} else {
								alert(JSON.stringify(tbl_data.data[0].id));
							}
							table.reload();
						}
						if(event1 === "edit") {
							layer.open({
								title: "编辑资产",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
							table.reload();
						}
					});


					table.on("tool(test)", function(obj) {
						var myevent = obj.event;
						var data = obj.data;
						if(myevent == "row_edit") {
							layer.open({
								title: "添加用户",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
						
						}
						
						$("#uname").val(data.id);
						$("#upwd").val(data.showValue);
						$("#date").val(data.class);
						$("#min").val(data.desc);
						$("#max").val(data.name);
						$("#nx").val(data.data)
					});


					//下拉选数据
					$(function(){
     	           $.ajax({
     		         type:"get",
     		          url:"dataJSON/selectDict5.json",
     		           success:function(result){
     			         var seoption="";
     			         $.each(result.select,function(index,value){
     				     seoption+="<option>"+value+"</option>";
     			         })
     			         $("#selectId5").append(seoption);
     			        form.render();
     		            }
     	               });
     
                       })
				});


			function toIndex() {


				$('#mainFrame').load('welcome.html');
			}
		</script>
		<script type="text/html" id="frm_add">
			<div>
				资产编号：<input id="uname" type="text" class="layui-input" placeholder="请输入资产编号" /><br /> 资产名称：
				<input id="upwd" type="text" class="layui-input" placeholder="请输入资产名称" /><br />品牌：
				<input id="date" type="text" class="layui-input" placeholder="请输入品牌" /><br /> 型号：
				<input id="min" type="text" class="layui-input" placeholder="请输入型号" /><br />供货商： 
				<input id="max" type="text" class="layui-input" placeholder="请输入供货商" />
			</div>


		</script>
		</script>
	</body>

</html>